Skip to content

Conversation

colshrapnel
Copy link

Connecting in every data class is a sure bad practice, and anyone who would try to extend the previously used approach to other classes will end up with tens of simultaneous connections to the database from the same PHP instance.

So a database connection should be instantiated only once and then passed to all objects as a constructor parameter.

Given this lesson is linked on the PHPTheRightWay, it shouldn't promote a bad practice, even for sake of simplification.

…ery class

Connecting in every data class is a sure bad practice, and anyone who would try to extend the previously used approach to other classes will end up with tens of simultaneous connections to the database from the same PHP instance. 

So a database connection should be instantiated only once and then passed to all objects as a constructor parameter.

Given this lesson is linked on the PHPTheRightWay, it shouldn't promote a bad practice, even for sake of simplification.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant